package javaCode.chapter07.Homework.homework10;

/*
编写Doctor类 {name,age,job,gender,sal}
相应的getter() 和 setter()方法，5个参数的构造器，重写父类的equals()方法：public boolean equals(Object obj),
并判断测试类中创建的两个对象是否相等。相等就是判断属性是否相同
 */
public class Doctor {
    private String name;
    private int age;
    private String job;
    private String gender;
    private double sal;

    //重写父类的equals()方法：public boolean equals(Object obj),
    //并判断测试类中创建的两个对象是否相等。相等就是判断属性是否相同
    public boolean equals(Object obj) {
        //判断两个对象比较是否相同
        if (this == obj) {
            return true;
        }
        //判断obj 是否为 Doctor类型 或子类
        if (!(obj instanceof Doctor)) {
            return false;
        }

        //向下转型, 因为obj的运行类型是Doctor或者其子类型
        Doctor doctor = (Doctor) obj;
        return doctor.name.equals(this.name) && doctor.age == this.age && doctor.job.equals(this.job) && doctor.gender.equals(this.gender) && doctor.sal == this.sal;

    }

    public Doctor(String name, int age, String job, String gender, double sal) {
        this.name = name;
        this.age = age;
        this.job = job;
        this.gender = gender;
        this.sal = sal;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getJob() {
        return job;
    }

    public void setJob(String job) {
        this.job = job;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public double getSal() {
        return sal;
    }

    public void setSal(double sal) {
        this.sal = sal;
    }
}
